
<%@include file="/WEB-INF/common/taglibs.jsp"%>
<script type="text/javascript"
	src="${ctx}/resources/js/datatable-query.js"></script>
<style>
.table-notification {
	padding: 0px 7px 0px 7px;
	color: #fff;
	background: #ed7a53;
	border-radius: 2px;
	-webkit-border-radius: 2px;
	-moz-border-radius: 2px;
	font-weight: 700;
	font-size: 12px;
	font-family: Tahoma;
	position: absolute;
	right: -10px;
	-webkit-box-shadow: 0px 1px 0px 0px rgba(0, 0, 0, 0.2);
	-moz-box-shadow: 0px 1px 0px 0px rgba(0, 0, 0, 0.2);
	box-shadow: 0px 1px 0px 0px rgba(0, 0, 0, 0.2);
	text-shadow: none;
}
</style>
<div class="row-fluid">
	<div class="span12">
		<div class="box gradient">
			<div class="title">
				<h4>
					<span>Post</span>
				</h4>
				<a href="#" class="minimize">Minimize</a>
			</div>
			<div class="content scrollable clearfix">
				<table class="ajaxTable display table table-bordered">
					<thead>
						<tr>
							<th><a id="select_all"><span
									class="icomoon-icon-checkmark-2"></span></a></th>
							<th>Title</th>
							<th>Key</th>
							<th>Cover</th>
							<th>Create Day</th>
							<th>Online</th>
							<th>Action</th>
						</tr>
					</thead>
				</table>
			</div>
		</div>

	</div>

	<a href="${ctx}/admin/post/create/" class="btn btn-info"> <span
		class="icon12 icomoon-icon-plus white"></span> New
	</a>

</div>



<script type="text/javascript">
	var render = false;
	$(document).ready(function() {
		johnny.oTable = $('.ajaxTable').dataTable({
			"bLengthChange" : true,
			"aoColumnDefs" : [ {
				'bSortable' : false,
				'aTargets' : [ 0, 6 ]
			} ],
			"sAjaxSource" : '${ctx}/admin/post/',
			"fnInitComplete" : function(oSettings, json) {
			}
		});
		var name = $("<input>").attr({
			type : "text",
			field : "title",
			op : "cn",
			placeholder : "Title",
			class : "filterdata"
		});
		johnny.initTableQuery(name);
		
		
		
		
		var del = {
				id : 'del',
				text : 'del',
				domain : "Post",
				operation : "Del",
				url : "${ctx}/admin/post/del/"
			};
			johnny.tableBtn(del);
		
		
		
		
		var online = {
			id : 'online',
			text : 'online',
			domain : "Post",
			operation : "Online",
			url : "${ctx}/admin/post/online/"
		};
		johnny.tableBtn(online);

		var offline = {
			id : 'offline',
			text : 'offline',
			domain : "Post",
			operation : "Offline",
			url : "${ctx}/admin/post/offline/"
		};
		johnny.tableBtn(offline);

	});
	function updateGrid() {
		window.clearTimeout(oTime);
		oTime = setTimeout(function() {
			oTable.fnDraw();
		}, 500);
	}

	var columnHeader = [ '', 'title', 'keyUrl', 'coverURL', 'createDate',
			'online' ];
	var QueryData = function(aoData) {
		return johnny.initQueryData(aoData, columnHeader);
	}

	var DataTableForm = function(json, echo) {
		var dataArray = new Array();
		for (var i = 0; i < json.result.length; i++) {
			var subArray = new Array();

			var link = "${ctx}/admin/post/" + json.result[i].id + "/edit/";
			var detail = "${ctx}/admin/post/" + json.result[i].id + "/detail/";
			var value = johnny.getForSelect(json.result[i].id);
			subArray.push(value);
			subArray.push(json.result[i].title);
			subArray.push(json.result[i].keyUrl);
			subArray.push(johnny.getImageHtml(json.result[i].coverURL));
			subArray.push(json.result[i].createDate);
			subArray.push(json.result[i].online);
			var conf = [

			{
				link : link,
				text : 'edit',
				css : 'icomoon-icon-eyedropper'
			}, {
				link : detail,
				text : 'detail',
				css : 'icomoon-icon-pencil'

			} ];
			subArray.push(johnny.getGridLink(conf));
			dataArray.push(subArray);
		}
		return {
			sEcho : echo,
			iTotalRecords : json.totalCount,
			iTotalDisplayRecords : json.totalCount,
			aaData : dataArray
		};
	}
</script>